-
Notifications
You must be signed in to change notification settings - Fork 826
Cancel nukes when accepting alliance via radial menu #3155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…eptance way Fixes #3154
WalkthroughMoved nuke-cancellation from the old alliance-reply execution into core game acceptance logic; replaced the reply intent/execution with a reject flow and added an explicit AllianceRejectExecution. Tests and client wiring updated to use request/counter-request or explicit reject flows. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to just remove this execution? And then events display and radial menu can just send AllianceRequest? Then all alliance logic would be in a single file, and we can move cancelNukesBetweenAlliedPlayers there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I centralised acceptance logic in AllianceRequestExecution and created a new AllianceRejectExecution to handle rejections, because:
- semantics: you'll never look for the rejection path inside Alliance Request Execution
- SRP: adding a new parameter to
AllianceRequestExecutionto branch out its logic and handle rejections felt really wrong to me
src/core/game/GameImpl.ts
Outdated
| }); | ||
| } | ||
|
|
||
| private cancelNukesBetweenAlliedPlayers(p1: Player, p2: Player): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GameImpl should ideally be just a container to hold game state and not have much complex logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to AllianceRequestExecution
| const requestor = mg.player(this.requestorID); | ||
|
|
||
| if (requestor.isFriendly(this.recipient)) { | ||
| console.warn("already allied"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here and on line 28 can you log something like:
console.warn("[AllianceRejectExecution] Player ${this.requestorID} cannot reject alliance with ${this.recipient.id}, already allied"
| // Cancel incoming nukes between players | ||
| cancelNukesBetweenAlliedPlayers(this, requestor, recipient); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this also adds a lot of logic into GameImpl, gameimpl should ideally just store & update state. Can this be removed?
Same with line 337 & 338
Resolves #3154
Description:
#2716 introduced nuke cancellation logic on alliance acceptance via
AllianceRequestReplyExecution. The radial menu action, though, callsAllianceRequestExecutioninstead, which accepts the alliance if a request has already been made by the other player.This PR moves the nuke cancellation logic to
GameImpl, hooking into theacceptAllianceRequestmethod, therefore accounting for every alliance acceptance, regardless of the specific action that brought to that.Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
deshack_82603